;!include MUI2.nsh

Name "MtgPrinter"
OutFile "MtgPrinterInstall.exe"

InstallDir "$PROGRAMFILES\MtgPrinter"

;LicenseData license.txt
;Page license
Page directory
Page instfiles
UninstPage uninstConfirm
UninstPage instfiles

!include "DotNET.nsh"
!include "LogicLib.nsh"

!define DOTNET_VERSION "3.5"
!define BinariesDirectory "C:\Users\Alek\Documents\Visual Studio 2010\Projects\MtgPrinter\MtgPrinter\bin\Release"

Section "MtgPrinter"
 SectionIn RO
  !insertmacro CheckDotNET ${DOTNET_VERSION}
;;---------------------

  
  ;;------------------
  SetOutPath $INSTDIR
  File "${BinariesDirectory}\MtgPrinter.exe"
  File "${BinariesDirectory}\GeneralTools.dll"
  File "${BinariesDirectory}\HtmlAgilityPack.dll"
  File "${BinariesDirectory}\itextsharp.dll"
  File "${BinariesDirectory}\MtgPrinter.pdb"
  WriteUninstaller "MtgPrinter_uninstall.exe"

  SetShellVarContext all
  CreateDirectory "$SMPROGRAMS\MtgPrinter"
  CreateShortCut "$SMPROGRAMS\MtgPrinter\MtgPrinter.lnk" "$INSTDIR\MtgPrinter.exe"
  CreateShortCut "$SMPROGRAMS\MtgPrinter\UninstallMtgPrinter.lnk" "$INSTDIR\MtgPrinter_uninstall.exe"

  SetShellVarContext current
  CreateShortCut "$DESKTOP\MtgPrinter.lnk" "$INSTDIR\MtgPrinter.exe"
  
	MessageBox MB_OK "You have successfully installed MtgPrinter."
SectionEnd

Section "Uninstall"
	; remove registry keys
	;DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\WebappInst"
	;DeleteRegKey HKLM SOFTWARE\WebappInst

	; remove files and directories
	Delete $INSTDIR\MtgPrinter.exe
	Delete $INSTDIR\GeneralTools.dll
	Delete $INSTDIR\HtmlAgilityPack.dll
	Delete $INSTDIR\itextsharp.dll
	Delete $INSTDIR\MtgPrinter.pdb
	Delete $INSTDIR\MtgPrinter_uninstall.exe

	RMDir "$INSTDIR"

	SetShellVarContext all

	Delete "$SMPROGRAMS\MtgPrinter\MtgPrinter.lnk"
	Delete "$SMPROGRAMS\MtgPrinter\UninstallMtgPrinter.lnk"

	RMDir "$SMPROGRAMS\MtgPrinter"
	Delete "$DESKTOP\MtgPrinter.lnk"
	
	SetShellVarContext current
	RMDir /r "$APPDATA\MtgPrinter"
	
	Delete "$SMPROGRAMS\MtgPrinter\MtgPrinter.lnk"
	Delete "$SMPROGRAMS\MtgPrinter\UninstallMtgPrinter.lnk" 
	RMDir "$SMPROGRAMS\MtgPrinter"
	
	Delete "$DESKTOP\MtgPrinter.lnk"
	
	MessageBox MB_OK "You have successfully uninstalled MtgPrinter."

SectionEnd

